package top.frsf.object.plant;

import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import top.frsf.constants.ImageConstant;
import top.frsf.enums.BulletTypeEnum;
import top.frsf.factory.BulletFactory;
import top.frsf.object.bullet.BulletObject;
import top.frsf.object.bullet.PesBullet;
import top.frsf.object.env.Grass;
import top.frsf.object.zombie.ZomObject;
import top.frsf.panel.GamePanel;
import top.frsf.starter.impl.BulletStarter;
import top.frsf.starter.impl.EnvStarter;
import top.frsf.starter.impl.PlantStarter;
import top.frsf.starter.impl.ZomStarter;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;

/**
 * 豌豆射手
 *
 * @author FRSF
 * @since 2025/8/3 0:35
 */
@Slf4j
public class Pea extends PlantObject {

    private static final Image[] imageList = new Image[13];

    static {
        try {
            for (int i = 0; i < imageList.length; i++) {
                String imageUrl = String.format(ImageConstant.Plant.PEA, i);
                imageList[i] = ImageIO.read(new File(imageUrl));
            }
        } catch (Exception e) {
            log.error("图片加载失败", e);
            throw new RuntimeException(e);
        }
    }

    public Pea(int x, int y) {
        super(ImageConstant.Plant.PEA, x, y, 70, 70, 50, BulletTypeEnum.PEA_BULLET);
        addAnimation(ImageConstant.Plant.PEA, imageList);
        switchAnimation(ImageConstant.Plant.PEA, 100, true);
        setAttackCd(1500);
    }
}
